from Structure import Stack

# 用栈思想解决匹配括号问题 LIFO Last In First Out
def parChecker(symbolString):
    s = Stack()
    balanced = True
    index = 0
    while index < len(symbolString) and balanced:
        symbol = symbolString[index]
        if symbol == "(":
            s.push(symbol)
        else:
            if s.isEmpty():
                balanced =  False
            else:
                s.pop()
        index = index + 1

    if balanced and s.isEmpty():
        return True
    else:
        return False

string = '(()())'
if (parChecker(string)):
    print("well done")
else:
    print("something wrong!")